
use WebSecurity;
GO
-- Drop stored procedure if it already exists
IF EXISTS (
  SELECT * 
    FROM INFORMATION_SCHEMA.ROUTINES 
   WHERE SPECIFIC_CATALOG = N'WebSecurity' 
	 AND SPECIFIC_SCHEMA = N'dbo'
     AND SPECIFIC_NAME = N'UserProfile_udt' 
)
   DROP PROCEDURE dbo.UserProfile_udt
GO
create procedure dbo.UserProfile_udt
	@UserId Int,
	@UserName NVarChar(30),
	@TS varbinary(8),
	@CreatedBy VarChar(50),
	@CreatedDt DateTime,
	@ModifiedBy VarChar(50),
	@ModifiedDt DateTime,
	@IsActive Bit,
	@FirstName NVarChar(50),
	@LastName NVarChar(50),
	@Address NVarChar(250),
	@City NVarChar(50),
	@Region NVarChar(50),
	@PostalCode NVarChar(25),
	@OfficePhone NVarChar(25),
	@CellPhone NVarChar(25),
	@Title NVarChar(100),
	@RowsAffected int = null OUTPUT 
	
--*************************************************************
--Created By: trooks
--Name: dbo_UserProfile_udt
--Table: UserProfile
--Database: WebSecurity
--Created Date: 01/21/2013 00:00:00
--*************************************************************

as
    Begin Try
		update [dbo].UserProfile
        Set

		UserName = @UserName, 
		CreatedBy = @CreatedBy, 
		CreatedDt = @CreatedDt, 
		ModifiedBy = @ModifiedBy, 
		ModifiedDt = @ModifiedDt, 
		IsActive = @IsActive, 
		FirstName = @FirstName, 
		LastName = @LastName, 
		Address = @Address, 
		City = @City, 
		Region = @Region, 
		PostalCode = @PostalCode, 
		OfficePhone = @OfficePhone, 
		CellPhone = @CellPhone, 
		Title = @Title 
    where
		 @UserId = UserId
		AND @TS = TS
		Set @RowsAffected = @@ROWCOUNT;
		return 0;	
	END TRY
	BEGIN CATCH
		Set @RowsAffected = 0;
		EXEC dbo.uspLogError;
		return -1;
	END CATCH
	
GO
GRANT EXECUTE ON [WebSecurity].[dbo].[UserProfile_udt] to PORTAL_WebSecurity
GO













